{extend name="common/base" /}
{block name="styles"}
   <style>
      .flex_item{
         display: flex;align-items: center;
      }
      .mr-10{
         margin-right: 10px;
      }
   </style>
{/block}
{block name="body"} 
<div class="head_box">
    <i class="layui-icon layui-icon-left" onclick="back()"></i>
    <div class="t1">计划</div>
 </div>
 <main class="main_body">
    <div class="title_nav">
      {if $role && $role.is_admin == 1} 
         <a   href="plan_add.html">添加计划</a>       
         <a  href="plan_list.html">管理计划</a>
      {/if}
       <a class="active" href="/plan_today.html">今日计划</a>
    </div>
    <div class="plan_ul">
       <div class="d-flex al-c jc-fe ftc">
          <span id="car_btn">选择车型</span>
          <i class="layui-icon layui-icon-right"></i>
       </div>

       {volist name="list" id="vo"} 
         <div class="plan_item">
            <div class="b1">
               <div class="time_box flex_item">
                  <img class="date mr-10" src="__ROOT__/static/images/date.png">
                  <div>
                     <div>{$vo.start_time}</div>
                      <div>{$vo.end_time}</div>
                  </div>
                  
               </div>
               <div>
                  <span>{$vo.produce_no}/{$vo.segment_type_no}/{$vo.stage.name}</span> 
                  <!-- <i class="layui-icon layui-icon-right"></i> -->
               </div>
 
            </div>
            <div class="b2">
               <div class="flex_item">
                  <div>目前状态：</div>
                  {if $vo.status == 0} 
                     <div class="layui-badge"> {$vo.status_text}</div>
                  {/if}
                  {if $vo.status == 1} 
                     <div class="layui-badge layui-bg-blue"> {$vo.status_text}</div>
                  {/if}
                  {if $vo.status == 2} 
                  <div class="layui-badge layui-bg-green"> {$vo.status_text}</div>
               {/if}
                 
               </div>
               <div class="flex_item " style="justify-content:space-between;">
                  <div>计划时长 : {$vo.circle*60 | round}分钟</div>
                  <div>实际作业时长 : {$vo.true_circle}分钟</div>
               </div>
               <div>注意事项：{$vo.remarks}</div>
               <div>历史问题回顾</div>
            </div>
            
         </div>
       {/volist}

    </div>

 </main>
 <div class="car_change" id="car_change">

   <div class="car" style="width: 75%;">
       <div class="car_name">
           <label>选择车型</label>
           <select name="car_id" id="carSelect">
                  <option value="0">全部</option>
               {volist name="carne_list" id="vo"}
                   <option {if $car_id == $vo.id} selected {/if} value="{$vo.id}">{$vo.name}</option>
               {/volist}
           </select>
       </div>
       <div class="car_button">
           <button id="closebtn" type="button">关闭</button>
           <button type="button" id="submitbtn" class="select_car">提交</button>
       </div>
   </div>
</div>


     
      
 </div>

{/block}
{block name="js"}
<script>
 function back(){
      window.location.href="/index"
    }
layui.use(['form', 'laydate', 'util'], function () {
      var form = layui.form;
      var layer = layui.layer;
      var laydate = layui.laydate;
      var util = layui.util;

      // 日期
      laydate.render({
         elem: '#date'
      }); laydate.render({
         elem: '#date1'
      });
      $("#car_btn").on("click",function(){
        $('.car_change').show();
        })
        $("#closebtn").on("click",function(){
            $('.car_change').hide();
        })

         // 关闭按钮点击事件
    $('#closebtn').click(function() {
        $('#car_change').hide();  // 隐藏 div
    });

    // 提交按钮点击事件
    $('#submitbtn').click(function() {
        // 获取 select 选择的车型 ID
        var carId = $('#carSelect').val();
        
        // 检查是否选择了车型
        if (carId === '') {
            layer.msg('请选择车型');
            return;
        }

        var currentUrl = window.location.href;
        // 创建一个 URL 对象
        var url = new URL(currentUrl);
        
        // 更新 car_id 参数
        url.searchParams.set('car_id', carId);
        
        // 重定向到新的 URL，刷新页面
        window.location.href = url.toString();
    });

});
 </script>
{/block}

